package com.xk857.db;

import com.xk857.pojo.Car;
import com.xk857.pojo.Sense;
import com.xk857.pojo.TrafficLightConfiguration;

import java.util.ArrayList;
import java.util.List;


/**
 * 模拟数据库
 *
 * @Author CV大魔王
 * @Date 2020.1.20
 */
public class CarDB {

    public static List<Car> carList = new ArrayList<>();
    public static List<TrafficLightConfiguration> intersectionList = new ArrayList<TrafficLightConfiguration>();
    public static List<Sense> senseList = new ArrayList<>();

    /**
     * 初始化小车数据
     */
    public static void initCar() {
        Car car = new Car(1, "Start", 300000000, 26);
        carList.add(car);
        car = new Car(2, "Stop", 200000000, 37);
        carList.add(car);
        car = new Car(3, "Start", 100000000, 68);
        carList.add(car);
    }

    /**
     * 初始化红绿灯配置信息
     */
    public static void initIntersection() {
        TrafficLightConfiguration traffic = new TrafficLightConfiguration();
        traffic = new TrafficLightConfiguration(1, 55, 25, 3);
        intersectionList.add(traffic);
        traffic = new TrafficLightConfiguration(2, 25, 55, 5);
        intersectionList.add(traffic);
        traffic = new TrafficLightConfiguration(3, 40, 30, 5);
        intersectionList.add(traffic);
    }

    /**
     * 模拟传感器的值，返回时随机抽取
     */
    public static void initSense() {
        Sense sense = new Sense(8, 5919, 1711, 44, 28);
        senseList.add(sense);
        sense = new Sense(7, 3431, 3751, 36, 19);
        senseList.add(sense);
        sense = new Sense(5, 6976, 2749, 51, 26);
        senseList.add(sense);
        sense = new Sense(6, 5422, 1044, 47, 35);
        senseList.add(sense);
        sense = new Sense(9, 4130, 3518, 40, 21);
        senseList.add(sense);
        sense = new Sense(6, 5122, 4752, 32, 30);
        senseList.add(sense);
        sense = new Sense(7, 3840, 1099, 39, 28);
        senseList.add(sense);
        sense = new Sense(7, 4633, 2310, 47, 35);
        senseList.add(sense);


    }


}
